How to use Github Actions to syncronize code and compile your CSS/JS before deployment

I’ve been asking about this - and I think I figured it out today, so here goes.

This uses “integrated composer”, so, “normal” out of the box Drupal installs on Github.

I’m leaving out some details, but the basics are…

  1. You want to crate your drupal site in the Pantheon dashboard as normal and initialize the site for the first time on the DEV environment. (by initialize, I mean complete the install.php process).

  2. git clone the pantheon repo to your localhost.

  3. Create an empty github repo.

  4. Add the github repo as a remote on your localhost.

  5. Rename the pantheon repo as “pantheon” and the github repo as “origin”, This just simpifies keeping straight what’s “origin” and what’s not…

From here on out you are NOT pushing to Pantheon’s repo, ever… all work goes through Github.

  1. In your project .gitignore file,

But something like this, at the top : https://gist.github.com/alphex/6fba44d6a5f56f3768c6b65632f59caf.

In my project, this is literally the first 6 lines of the .gitignore file.

THEN, follow this guide https://medium.com/swlh/pantheon-and-github-actions-automated-deployments-via-github-actions-c245aa954797 to set up the basic structure of your workflows.

I’ve made some changes based on this example https://medium.com/bluecadet/pantheon-and-github-actions-1b9b1dbd5746

Which I’ve created in these two workflow files.

These two files handle pushing branches to github, which syncronizes them to pantheon in near real time, after the Actions fire.

This will let you create multidevs based on the branches on the pantheon dashboard (or via Terminus) since the branch is syncronzied to Pantheon when you push to Github.

Any additional pushes to that branch, will go to pantheon as well.

You handle your merges in github, and the main branch gets pushed to master.

I hope this helps!

2 Likes

This is great, thanks for sharing! :star2:

Thanks for sharing! I see this as a question to be resolved by our Docs: https://github.com/pantheon-systems/documentation/issues/8903

@stevepersch.pantheondashboard.gmail.com
Steven, thanks – I am going to write up a much more detailed break down of what I did to build this, and how it works, and will share back to this thread when its done.

Let me know if you have any questions.

1 Like